﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace MaterialDemo.DataEntity.Entities
{
    public partial class EFDbContext : DbContext
    {
        public EFDbContext()
        {

        }

        public EFDbContext(DbContextOptions<EFDbContext> options)
            : base(options)
        {
        }

        public virtual DbSet<DepartmentInfo> DepartmentInfo { get; set; }
        public virtual DbSet<GoodsCategory> GoodsCategory { get; set; }
        public virtual DbSet<GoodsConsumableInfo> GoodsConsumableInfo { get; set; }
        public virtual DbSet<GoodsConsumableInput> GoodsConsumableInput { get; set; }
        public virtual DbSet<GoodsEquipmentInfo> GoodsEquipmentInfo { get; set; }
        public virtual DbSet<GoodsEquipmentInput> GoodsEquipmentInput { get; set; }
        public virtual DbSet<Log> Log { get; set; }
        public virtual DbSet<PowerInfo> PowerInfo { get; set; }
        public virtual DbSet<RRoleInfoPowerInfo> RRoleInfoPowerInfo { get; set; }
        public virtual DbSet<RUserInfoRoleInfo> RUserInfoRoleInfo { get; set; }
        public virtual DbSet<RoleInfo> RoleInfo { get; set; }
        public virtual DbSet<UserInfo> UserInfo { get; set; }
        public virtual DbSet<WorkFlowInstance> WorkFlowInstance { get; set; }
        public virtual DbSet<WorkFlowInstanceStep> WorkFlowInstanceStep { get; set; }
        public virtual DbSet<WorkFlowModel> WorkFlowModel { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
        //    if (!optionsBuilder.IsConfigured)
        //    {
        //        //#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
        //        optionsBuilder.UseSqlServer("Server=.;Database=LDG_HopuGoods;uid=sa;pwd=123");
        //    }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<DepartmentInfo>(entity =>
            {
                entity.HasIndex(e => e.DepartmentId)
                    .HasName("IX_DepartmentInfo")
                    .IsUnique();
                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.DepartmentId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.DepartmentName)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.LeaderId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.ParentId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<GoodsCategory>(entity =>
            {
                entity.ToTable("Goods_Category");

                entity.Property(e => e.CategoryName)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Description).HasMaxLength(32);
            });

            modelBuilder.Entity<GoodsConsumableInfo>(entity =>
            {
                entity.ToTable("Goods_ConsumableInfo");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.GoodsId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Money).HasColumnType("money");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Specification).HasMaxLength(32);

                entity.Property(e => e.Unit)
                    .IsRequired()
                    .HasMaxLength(8);
            });

            modelBuilder.Entity<GoodsConsumableInput>(entity =>
            {
                entity.ToTable("Goods_ConsumableInput");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.AddUserId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.GoodsId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<GoodsEquipmentInfo>(entity =>
            {
                entity.ToTable("Goods_EquipmentInfo");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.Description).HasMaxLength(16);

                entity.Property(e => e.GoodsId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Money).HasColumnType("money");

                entity.Property(e => e.Name)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Specification).HasMaxLength(32);

                entity.Property(e => e.Unit)
                    .IsRequired()
                    .HasMaxLength(8);
            });

            modelBuilder.Entity<GoodsEquipmentInput>(entity =>
            {
                entity.ToTable("Goods_EquipmentInput");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.AddUserId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.GoodsId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<Log>(entity =>
            {
                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.Decription).HasMaxLength(128);
            });

            modelBuilder.Entity<PowerInfo>(entity =>
            {
                entity.HasIndex(e => e.PowerId)
                    .HasName("IX_PowerInfo")
                    .IsUnique();



                entity.Property(e => e.ActionUrl)
                    .IsRequired()
                    .HasMaxLength(128);



                entity.Property(e => e.Description).HasMaxLength(32);

                entity.Property(e => e.HttpMethod).HasMaxLength(4);

                entity.Property(e => e.MenuIconUrl).HasMaxLength(32);


                entity.Property(e => e.ParentId).HasMaxLength(16);

                entity.Property(e => e.PowerId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<RRoleInfoPowerInfo>(entity =>
            {
                entity.ToTable("R_RoleInfo_PowerInfo");

                entity.Property(e => e.PowerId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.RoleId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<RUserInfoRoleInfo>(entity =>
            {
                entity.ToTable("R_UserInfo_RoleInfo");

                entity.Property(e => e.RoleId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.UserId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<RoleInfo>(entity =>
            {
                entity.HasIndex(e => e.RoleId)
                    .HasName("IX_RoleInfo")
                    .IsUnique();

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.DelTime).HasColumnType("datetime");

                entity.Property(e => e.Description)
                    .IsRequired()
                    .HasMaxLength(32);

                entity.Property(e => e.RoleId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.RoleName)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<UserInfo>(entity =>
            {
                entity.HasIndex(e => e.UserId)
                    .HasName("IX_UserInfo")
                    .IsUnique();

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.DelTime).HasColumnType("datetime");

                entity.Property(e => e.DepartmentId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Email).HasMaxLength(32);

                entity.Property(e => e.PassWord)
                    .IsRequired()
                    .HasMaxLength(32)
                    .IsUnicode(false)
                    .IsFixedLength();

                entity.Property(e => e.PhoneNum).HasMaxLength(16);

                entity.Property(e => e.UserId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.UserName)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<WorkFlowInstance>(entity =>
            {
                entity.ToTable("WorkFlow_Instance");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.Description).HasMaxLength(64);

                entity.Property(e => e.InstanceId)
                    .IsRequired()
                    .HasMaxLength(64);

                entity.Property(e => e.NextReviewer).HasMaxLength(16);

                entity.Property(e => e.OutGoodsId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.Reason).HasMaxLength(64);

                entity.Property(e => e.UserId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<WorkFlowInstanceStep>(entity =>
            {
                entity.ToTable("WorkFlow_InstanceStep");

                entity.Property(e => e.InstanceId)
                    .IsRequired()
                    .HasMaxLength(64);

                entity.Property(e => e.NextReviewerId)
                    .IsRequired()
                    .HasMaxLength(16);

                entity.Property(e => e.ReviewReason).HasMaxLength(64);

                entity.Property(e => e.ReviewTime).HasColumnType("datetime");

                entity.Property(e => e.ReviewerId)
                    .IsRequired()
                    .HasMaxLength(16);
            });

            modelBuilder.Entity<WorkFlowModel>(entity =>
            {
                entity.ToTable("WorkFlow_Model");

                entity.Property(e => e.AddTime).HasColumnType("datetime");

                entity.Property(e => e.Description).HasMaxLength(64);

                entity.Property(e => e.Title)
                    .IsRequired()
                    .HasMaxLength(32);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
